/*
*
==============================================================================
*  Name        : 
*  Part of     : Omen Game Engine
*  Description : 
*  Version     : 1.0
*
*  Copyright (c) 2013 Lauri Kortevaara.
* 
==============================================================================
*/

#define OMEN_SOURCE 1

#include <OmenPropertyObject.h>

using namespace Omen;

/// <summary>Creates a new Omen::PropertyObject</summary>    
PropertyObject::PropertyObject( const std::wstring& strPropertyObjectName ) :
    m_name(strPropertyObjectName)
{
}

/// <summary>Copies an Omen::PropertyObject</summary>
PropertyObject::PropertyObject( const PropertyObject& other )
{
    m_name = other.m_name;
    m_properties = other.m_properties;
}

/// <summary>Destructs an Omen::PropertyObject</summary>
PropertyObject::~PropertyObject()
{
}

/// <summary>Comparison operator for Omen::PropertyObject</summary>
bool PropertyObject::operator == (const std::wstring& strPropertyObjectName) const
{
    return m_name == strPropertyObjectName;
}

/// <summary>Comparison operator for Omen::PropertyObject</summary>
bool PropertyObject::operator == (const Omen::PropertyObject& other) const
{
    return m_name == other.m_name;
}

/// <summary>Less than operator for Omen::PropertyObject</summary>
bool PropertyObject::operator < ( const Omen::PropertyObject& other ) const
{
    return m_name < other.m_name;
}

/// <summary>Adds a new property to the object</summary>
void PropertyObject::setProperty( const std::wstring& strPropertyName, const std::wstring& strPropertyValue )
{
    m_properties[strPropertyName] = strPropertyValue;
}

/// <summary>Returns true if object has a property with given name, false otherwise</summary>
bool PropertyObject::hasProperty( const std::wstring& strPropertyName ) const
{
    return m_properties.find( strPropertyName ) != m_properties.end();
}

/// <summary>Returns a vector of property names added to the object</summary>
void PropertyObject::getPropertyNames( std::vector< std::wstring >& listPropertyNames ) const
{
    for( std::map< std::wstring, Omen::Property >::const_iterator iter = m_properties.begin();
         iter != m_properties.end(); ++iter )
         listPropertyNames.push_back( iter->first );
}
        
/// <summary>Returns the value of given property</summary>
Omen::Property& PropertyObject::property( const std::wstring& strPropertyName )
{
    static Omen::Property null_prop;
    if( m_properties.find( strPropertyName ) != m_properties.end() )
        return m_properties.at( strPropertyName );
    else
        return null_prop;
}
    

/// EOF